#ifndef LAYOUT_EDITOR_H
#define LAYOUT_EDITOR_H

#include "LayoutPanel.h"
#include "LayoutProperty.h"
#include "LayoutViewEd.h"

class LayoutEditor
{
	DECLARE_SINGLETON(LayoutEditor);

public:
	tEvent1<MGUI_Widget *> eventEditWidgetChanged;
	tEvent1<TString128> eventNameChanged;
	tEvent1<MGUI_Rect> eventRectChanged;
	tEvent1<MGUI_Layout *> eventOpenLayout;

public:
	LayoutEditor();
	~LayoutEditor();

	void Layout();

	void _createLayout();
	void _distroyLayout();

	void Open();
	void Save();

	MGUI_Widget * GetEditWidget() { return mEditWidget; }
	MGUI_Layout * GetEditLayout() { return mEditLayout; }

	void notifyEditWidgetChanged(MGUI_Widget * _widget);
	void notifyNameChanged(TString128 _name);
	void notifyRectChanged(MGUI_Rect _rect);

protected:
	void _setLayoutFile(const TString128 & filename);

protected:
	LayoutPanel * mLayoutPanel;
	LayoutProperty * mLayoutProperty;
	LayoutViewEd * mLayoutViewEd;

	MGUI_Layout * mEditLayout;
	MGUI_Widget * mEditWidget;

	TString128 mFilename;

protected:
	void OnEditorModeChanged_(eEditorMode _mode);

	tListener1<LayoutEditor, eEditorMode> OnEditorModeChanged;
};

#endif